define(["jquery", "easy-admin", "xm-select"], function ($, ea) {
    let laydate = layui.laydate
        , form = layui.form;
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'coupon.receive/index',
        add_url: 'coupon.receive/add',
        edit_url: 'coupon.receive/edit',
        delete_url: 'coupon.receive/delete',
        export_url: 'coupon.receive/export',
        modify_url: 'coupon.receive/modify',
        push_url: 'coupon.receive/push'
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'delete', 'export'],
                minWidth: 90,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 90},
                    {field: 'get_user.nickName', title: '领取人', minWidth: 140},
                    {field: 'get_user.avatarUrl', title: '头像', minWidth: 90, search: false, templet: ea.table.image},
                    {field: 'coupon.title', title: '优惠券名称', minWidth: 120},
                    {field: 'end_time', title: '过期时间', minWidth: 200, templet: ea.table.date},
                    {
                        field: 'status',
                        title: '状态',
                        search: 'select',
                        selectList: {
                            0: "未使用", 1: "已使用", 2: "已过期"
                        },
                        width: 180
                    },
                    {field: 'create_time', title: '创建时间', width: 160, search: 'range'},
                    {
                        width: 250, title: '操作', templet: ea.table.tool, operat: [
                            [{
                                text: '推送',
                                extra: 'name',
                                url: init.push_url,
                                method: 'request',
                                auth: 'push',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: '',
                                show: [
                                    {"name": "push", "value": "0"}
                                ]
                            }, {
                                text: '编辑',
                                extra: 'name',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                                show: [
                                    {"name": "push", "value": "0"}
                                ]
                            }],
                            'delete']
                    },
                ]],
            });

            ea.listen();
        },
        add: function () {

            ea.listen();
        },
        edit: function () {

            ea.listen();
        },
    };
    return Controller;
});